#include <stdio.h>

int main()
{
    long long int n,m,sum=0,a[99999],b[99999],*p,*p1,*p2;
    long long int i,j,k;
    scanf("%lld %lld",&m,&n);
    getchar();

    for(p=a;p<a+m;p++)
        scanf("%lld",p);
    
    for(p=a,p1=b;p<=a+m-n,p1<=b+m-n;p++,p1++)//相邻n个数相加
    {   
    	for(p2=p;p2<p+n;p2++)
            sum=sum+*p2;
        *p1=sum;
        sum=0;
    }

    for(j=0;j<=m-n-1;j++)//冒泡算法排序
        for(i=0;i<=m-n-1-j;i++)
            if(b[i]>b[i+1])
            {
                k=b[i];
                b[i]=b[i+1];
                b[i+1]=k;
            }
    
    printf("%lld",b[0]);
    return 0;
}